/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.germinus.telcoblocks.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.germinus.telcoblocks.Centralita_VOIP;
import org.germinus.telcoblocks.Enlace;
import org.germinus.telcoblocks.MediaServer;
import org.germinus.telcoblocks.NodoRED;
import org.germinus.telcoblocks.RED;
import org.germinus.telcoblocks.Servidor_APP_SIP;
import org.germinus.telcoblocks.Servidor_VOIP;
import org.germinus.telcoblocks.TelcoblocksPackage;
import org.germinus.telcoblocks.Terminal;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>RED</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.germinus.telcoblocks.impl.REDImpl#getTerminales <em>Terminales</em>}</li>
 *   <li>{@link org.germinus.telcoblocks.impl.REDImpl#getEnlaces <em>Enlaces</em>}</li>
 *   <li>{@link org.germinus.telcoblocks.impl.REDImpl#getServidor_APP_SIP <em>Servidor APP SIP</em>}</li>
 *   <li>{@link org.germinus.telcoblocks.impl.REDImpl#getServidor_VOIP <em>Servidor VOIP</em>}</li>
 *   <li>{@link org.germinus.telcoblocks.impl.REDImpl#getCentralita_VOIP <em>Centralita VOIP</em>}</li>
 *   <li>{@link org.germinus.telcoblocks.impl.REDImpl#getMediaServer <em>Media Server</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class REDImpl extends EObjectImpl implements RED {
	/**
	 * The cached value of the '{@link #getTerminales() <em>Terminales</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTerminales()
	 * @generated
	 * @ordered
	 */
	protected EList<Terminal> terminales;

	/**
	 * The cached value of the '{@link #getEnlaces() <em>Enlaces</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEnlaces()
	 * @generated
	 * @ordered
	 */
	protected EList<Enlace> enlaces;

	/**
	 * The cached value of the '{@link #getServidor_APP_SIP() <em>Servidor APP SIP</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServidor_APP_SIP()
	 * @generated
	 * @ordered
	 */
	protected Servidor_APP_SIP servidor_APP_SIP;

	/**
	 * The cached value of the '{@link #getServidor_VOIP() <em>Servidor VOIP</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServidor_VOIP()
	 * @generated
	 * @ordered
	 */
	protected Servidor_VOIP servidor_VOIP;

	/**
	 * The cached value of the '{@link #getCentralita_VOIP() <em>Centralita VOIP</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCentralita_VOIP()
	 * @generated
	 * @ordered
	 */
	protected Centralita_VOIP centralita_VOIP;

	/**
	 * The cached value of the '{@link #getMediaServer() <em>Media Server</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMediaServer()
	 * @generated
	 * @ordered
	 */
	protected MediaServer mediaServer;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected REDImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TelcoblocksPackage.Literals.RED;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Terminal> getTerminales() {
		if (terminales == null) {
			terminales = new EObjectContainmentEList<Terminal>(Terminal.class, this, TelcoblocksPackage.RED__TERMINALES);
		}
		return terminales;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Enlace> getEnlaces() {
		if (enlaces == null) {
			enlaces = new EObjectContainmentEList<Enlace>(Enlace.class, this, TelcoblocksPackage.RED__ENLACES);
		}
		return enlaces;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Servidor_APP_SIP getServidor_APP_SIP() {
		return servidor_APP_SIP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetServidor_APP_SIP(Servidor_APP_SIP newServidor_APP_SIP, NotificationChain msgs) {
		Servidor_APP_SIP oldServidor_APP_SIP = servidor_APP_SIP;
		servidor_APP_SIP = newServidor_APP_SIP;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__SERVIDOR_APP_SIP, oldServidor_APP_SIP, newServidor_APP_SIP);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setServidor_APP_SIP(Servidor_APP_SIP newServidor_APP_SIP) {
		if (newServidor_APP_SIP != servidor_APP_SIP) {
			NotificationChain msgs = null;
			if (servidor_APP_SIP != null)
				msgs = ((InternalEObject)servidor_APP_SIP).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__SERVIDOR_APP_SIP, null, msgs);
			if (newServidor_APP_SIP != null)
				msgs = ((InternalEObject)newServidor_APP_SIP).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__SERVIDOR_APP_SIP, null, msgs);
			msgs = basicSetServidor_APP_SIP(newServidor_APP_SIP, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__SERVIDOR_APP_SIP, newServidor_APP_SIP, newServidor_APP_SIP));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Servidor_VOIP getServidor_VOIP() {
		return servidor_VOIP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetServidor_VOIP(Servidor_VOIP newServidor_VOIP, NotificationChain msgs) {
		Servidor_VOIP oldServidor_VOIP = servidor_VOIP;
		servidor_VOIP = newServidor_VOIP;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__SERVIDOR_VOIP, oldServidor_VOIP, newServidor_VOIP);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setServidor_VOIP(Servidor_VOIP newServidor_VOIP) {
		if (newServidor_VOIP != servidor_VOIP) {
			NotificationChain msgs = null;
			if (servidor_VOIP != null)
				msgs = ((InternalEObject)servidor_VOIP).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__SERVIDOR_VOIP, null, msgs);
			if (newServidor_VOIP != null)
				msgs = ((InternalEObject)newServidor_VOIP).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__SERVIDOR_VOIP, null, msgs);
			msgs = basicSetServidor_VOIP(newServidor_VOIP, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__SERVIDOR_VOIP, newServidor_VOIP, newServidor_VOIP));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Centralita_VOIP getCentralita_VOIP() {
		return centralita_VOIP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCentralita_VOIP(Centralita_VOIP newCentralita_VOIP, NotificationChain msgs) {
		Centralita_VOIP oldCentralita_VOIP = centralita_VOIP;
		centralita_VOIP = newCentralita_VOIP;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__CENTRALITA_VOIP, oldCentralita_VOIP, newCentralita_VOIP);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCentralita_VOIP(Centralita_VOIP newCentralita_VOIP) {
		if (newCentralita_VOIP != centralita_VOIP) {
			NotificationChain msgs = null;
			if (centralita_VOIP != null)
				msgs = ((InternalEObject)centralita_VOIP).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__CENTRALITA_VOIP, null, msgs);
			if (newCentralita_VOIP != null)
				msgs = ((InternalEObject)newCentralita_VOIP).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__CENTRALITA_VOIP, null, msgs);
			msgs = basicSetCentralita_VOIP(newCentralita_VOIP, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__CENTRALITA_VOIP, newCentralita_VOIP, newCentralita_VOIP));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MediaServer getMediaServer() {
		return mediaServer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMediaServer(MediaServer newMediaServer, NotificationChain msgs) {
		MediaServer oldMediaServer = mediaServer;
		mediaServer = newMediaServer;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__MEDIA_SERVER, oldMediaServer, newMediaServer);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMediaServer(MediaServer newMediaServer) {
		if (newMediaServer != mediaServer) {
			NotificationChain msgs = null;
			if (mediaServer != null)
				msgs = ((InternalEObject)mediaServer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__MEDIA_SERVER, null, msgs);
			if (newMediaServer != null)
				msgs = ((InternalEObject)newMediaServer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TelcoblocksPackage.RED__MEDIA_SERVER, null, msgs);
			msgs = basicSetMediaServer(newMediaServer, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TelcoblocksPackage.RED__MEDIA_SERVER, newMediaServer, newMediaServer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TelcoblocksPackage.RED__TERMINALES:
				return ((InternalEList<?>)getTerminales()).basicRemove(otherEnd, msgs);
			case TelcoblocksPackage.RED__ENLACES:
				return ((InternalEList<?>)getEnlaces()).basicRemove(otherEnd, msgs);
			case TelcoblocksPackage.RED__SERVIDOR_APP_SIP:
				return basicSetServidor_APP_SIP(null, msgs);
			case TelcoblocksPackage.RED__SERVIDOR_VOIP:
				return basicSetServidor_VOIP(null, msgs);
			case TelcoblocksPackage.RED__CENTRALITA_VOIP:
				return basicSetCentralita_VOIP(null, msgs);
			case TelcoblocksPackage.RED__MEDIA_SERVER:
				return basicSetMediaServer(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TelcoblocksPackage.RED__TERMINALES:
				return getTerminales();
			case TelcoblocksPackage.RED__ENLACES:
				return getEnlaces();
			case TelcoblocksPackage.RED__SERVIDOR_APP_SIP:
				return getServidor_APP_SIP();
			case TelcoblocksPackage.RED__SERVIDOR_VOIP:
				return getServidor_VOIP();
			case TelcoblocksPackage.RED__CENTRALITA_VOIP:
				return getCentralita_VOIP();
			case TelcoblocksPackage.RED__MEDIA_SERVER:
				return getMediaServer();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TelcoblocksPackage.RED__TERMINALES:
				getTerminales().clear();
				getTerminales().addAll((Collection<? extends Terminal>)newValue);
				return;
			case TelcoblocksPackage.RED__ENLACES:
				getEnlaces().clear();
				getEnlaces().addAll((Collection<? extends Enlace>)newValue);
				return;
			case TelcoblocksPackage.RED__SERVIDOR_APP_SIP:
				setServidor_APP_SIP((Servidor_APP_SIP)newValue);
				return;
			case TelcoblocksPackage.RED__SERVIDOR_VOIP:
				setServidor_VOIP((Servidor_VOIP)newValue);
				return;
			case TelcoblocksPackage.RED__CENTRALITA_VOIP:
				setCentralita_VOIP((Centralita_VOIP)newValue);
				return;
			case TelcoblocksPackage.RED__MEDIA_SERVER:
				setMediaServer((MediaServer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TelcoblocksPackage.RED__TERMINALES:
				getTerminales().clear();
				return;
			case TelcoblocksPackage.RED__ENLACES:
				getEnlaces().clear();
				return;
			case TelcoblocksPackage.RED__SERVIDOR_APP_SIP:
				setServidor_APP_SIP((Servidor_APP_SIP)null);
				return;
			case TelcoblocksPackage.RED__SERVIDOR_VOIP:
				setServidor_VOIP((Servidor_VOIP)null);
				return;
			case TelcoblocksPackage.RED__CENTRALITA_VOIP:
				setCentralita_VOIP((Centralita_VOIP)null);
				return;
			case TelcoblocksPackage.RED__MEDIA_SERVER:
				setMediaServer((MediaServer)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TelcoblocksPackage.RED__TERMINALES:
				return terminales != null && !terminales.isEmpty();
			case TelcoblocksPackage.RED__ENLACES:
				return enlaces != null && !enlaces.isEmpty();
			case TelcoblocksPackage.RED__SERVIDOR_APP_SIP:
				return servidor_APP_SIP != null;
			case TelcoblocksPackage.RED__SERVIDOR_VOIP:
				return servidor_VOIP != null;
			case TelcoblocksPackage.RED__CENTRALITA_VOIP:
				return centralita_VOIP != null;
			case TelcoblocksPackage.RED__MEDIA_SERVER:
				return mediaServer != null;
		}
		return super.eIsSet(featureID);
	}

} //REDImpl
